package cn.iocoder.yudao.module.book.controller.app.user;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.book.controller.app.user.vo.UserReadingStatsRespVO;
import cn.iocoder.yudao.module.book.service.user.UserStatsService;
import cn.iocoder.yudao.module.book.service.users.userDTOService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Slf4j
@Tag(name = "用户 APP - 用户统计")
@RestController
@RequestMapping("/user/book")
public class AppUserStatsController {

    @Resource
    private UserStatsService userStatsService;
    
    @Resource
    private userDTOService userService;

    @GetMapping("/readSummary")
    @Operation(summary = "获取用户阅读统计")
    public CommonResult<UserReadingStatsRespVO> getUserReadingStats() {
        Long userId = userService.getCurrentUserId();
        log.info(String.valueOf(userId));
        UserReadingStatsRespVO result = userStatsService.getUserReadingStats(userId);
        return success(result);
    }

    @GetMapping("/todayReadList")
    @Operation(summary = "今日已读列表")
    public CommonResult<List<UserReadingStatsRespVO.ReadingRecordItem>> getTodayReadList() {
        Long userId = userService.getCurrentUserId();
        List<UserReadingStatsRespVO.ReadingRecordItem> result = userStatsService.getTodayReadList(userId);
        return success(result);
    }
}